/*
 ============================================================================
 Name		: TradeBlockQueryFunds.h
 Author	  : Zhang Jiawei
 Version	 : 1.0
 Copyright   : Your copyright notice
 Description : CTradeBlockQueryFunds declaration
 ============================================================================
 */

#ifndef TRADEBLOCKQUERYFUNDS_H
#define TRADEBLOCKQUERYFUNDS_H

// INCLUDES
#include "TradeBlock.h"
#include "Control.h"
#include "TableWidget.h"
#include "TradeBlockNetwork.h"

// CLASS DECLARATION

class CTradeBlockQueryVolume: public CTradeBlock, public MWidgetObserver, public MPushButtonObserver//, public MReqObserver
{
public:
    ~CTradeBlockQueryVolume();

    static CTradeBlockQueryVolume* NewL(CBaseBlock* bsBack = NULL);

    static CTradeBlockQueryVolume* NewLC(CBaseBlock* bsBack);

private:
    CTradeBlockQueryVolume(CBaseBlock* bsBack);

    void ConstructL();

public:
    void OnDraw(CFbsBitGc& g) const;

    void OnKeyDown(TInt keyCode);
    
    void OnMouseDown(const TPoint& aPt);
    
    void OnMouseMove(const TPoint& aPt);

    void OnMouseUp(const TPoint& aPt);

    void SizeChanged();    
    
    void ChangeFocus(TBool aFoucs, const TInt& keyCode);
    
    void BeforeBack();
    
protected:
    void AddTabs();

    void BeforeDraw(CFbsBitGc& g) const;
    
public:
	void PushButtonClicked();
	
public:
	TBool ProcessTradeNetworkMsg(TInt nError, TAny* p, const TDesC8& aBodyData);
	//TBool UpdateTradeNetwork(TInt nProgress);

public:
    // from MWidgetObserver
    void UpdateScreen();
    void SelectOneRow(TInt aRowIndex);
    void LoseFocus(const TInt& keycode);
    
    
private:
    void CreateTable();
    void CreateControls();
    void LayoutControls();
    void SetControlFocus(TBool bFocus, TInt nControlIndex);
    
    void InitNetworkData();
    TBool AppendNetworkData(__stock_hold_info_t* pStockArray);
    
private:
	typedef enum 
	{
		ENetworkStatus_None,
		ENetworkStatus_Req,
		ENetworkStatus_Resp
	}TNetworkStatus;
	
private:
    CTableWidget* iTable;
    
    CPushButton* 	iButtonSell;
    CPushButton* 	iButtonMore;
    TInt			iFocusControl;
    
    TNetworkStatus	iNetworkStatus;
    TInt			iNumberOfElement;
    TBool			iCanReq;
};

#endif // TRADEBLOCKQUERYFUNDS_H
